public class Serializer
extends java.lang.Object
Serializer is powerful utility class that allows you to serialize any object in Java using universal protocol system.
This system is generating code similar to JSON called SerialX but unlike JSON, SerialX is based on determinate order of arguments.
Also works with regular Java Base64 serialization.| Modifier and Type | Class and Description |
|---|---|
static class |
Serializer.ProtocolRegistry
ProtocolRegistry, place to register protocols!
|
| Modifier and Type | Field and Description |
|---|---|
static java.text.DecimalFormat |
decimalFormatter
Decimal formatter to format decimal numbers (double, float) with during serialization!
Default
DecimalFormat will round decimal numbers to 3 decimal places (format pattern #.###)!
Set this on null and decimal numbers will not be formated! Do this when you need accuracy! |
static boolean |
generateComments
Set this on true and program will generate comments and report!
|
static Serializer.ProtocolRegistry |
PROTOCOL_REGISTRY
This is serialization protocol registry.
|
static boolean |
useProtocolIfCan
Set this on true to force program to use SerializationProtocol also on java.io.Serializable objects.
|
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<java.lang.Object> |
LoadFrom(java.io.File f) |
static java.util.List<java.lang.Object> |
LoadFromString(java.lang.String str) |
static java.lang.String |
SerializeClassic(java.io.Serializable obj) |
static void |
SerializeTo(boolean append,
java.io.File f,
java.lang.Object... objs) |
static void |
SerializeTo(java.io.File f,
java.lang.Object... objs) |
static java.lang.String |
SerializeToString(java.lang.Object... objs) |
static java.lang.StringBuilder |
SerializeToString(java.lang.StringBuilder source,
java.lang.Object... objs) |
static java.lang.String[] |
splitValues(java.lang.String s)
This function supposed to not be called by user.
|
static java.lang.Object |
UnserializeClassis(java.lang.String objStr) |
public static final Serializer.ProtocolRegistry PROTOCOL_REGISTRY
public static boolean useProtocolIfCan
public static boolean generateComments
public static java.text.DecimalFormat decimalFormatter
DecimalFormat will round decimal numbers to 3 decimal places (format pattern #.###)!
Set this on null and decimal numbers will not be formated! Do this when you need accuracy!public static void SerializeTo(java.io.File f,
java.lang.Object... objs)
f - | File to write in. This must be a text file (recommended extension .srlx).objs - | Objects to serialize using SerialX.public static void SerializeTo(boolean append,
java.io.File f,
java.lang.Object... objs)
append - | When true, the new objects will be appended to files content (same objects will be also appended if there are some)!f - | File to write in. This must be a text file (recommended extension .srlx).objs - | Objects to serialize using SerialX.public static java.lang.String SerializeToString(java.lang.Object... objs)
objs - | Objects to serialize using SerialX.public static java.lang.StringBuilder SerializeToString(java.lang.StringBuilder source,
java.lang.Object... objs)
source - | Source StringBuilder to serialize objects into!objs - | Objects to serialize using SerialX.StringBuilder with objects serialized in SerialX code.public static java.lang.String SerializeClassic(java.io.Serializable obj)
throws java.io.IOException
obj - | Object to serialize using classic Java serialization.
Note: Slash will be replaced by back slash due to prevent conflict with // comment.java.io.IOException - - if an I/O error occurs while writing stream headerjava.lang.Base64public static java.util.List<java.lang.Object> LoadFrom(java.io.File f)
f - | Text file with serialized objects using SerialX.ArrayList if file is empty.
You can use negative indexes to get objects from back of this array since 1.1.0 (-1 = last element)!public static java.util.List<java.lang.Object> LoadFromString(java.lang.String str)
str - | SerialX string with serialized objects.ArrayList if string is empty.
You can use negative indexes to get objects from back of this array since 1.1.0 (-1 = last element)!public static java.lang.Object UnserializeClassis(java.lang.String objStr)
throws java.io.IOException,
java.lang.ClassNotFoundException
objStr - | String to unserialize by classic Java serialization.
Note: Backslashes will be replaced by regular slashes.java.io.IOException - - if an I/O error occurs while reading stream headerjava.lang.ClassNotFoundException - - Class of a serialized object cannot be found.Base64public static java.lang.String[] splitValues(java.lang.String s)
s - | String to split and check some syntax.